import {
	AuditOutlined,
	BarChartOutlined,
	DashboardOutlined,
	LaptopOutlined,
	MessageOutlined,
	TeamOutlined
} from '@ant-design/icons-vue';
import { createWebHistory, createRouter } from 'vue-router';

const routes = [
	{ path: '/', redirect: '/home' },
	{
		path: '/login',
		meta: { title: '登录' },
		component: () => import('../views/Login/index.vue')
	},
	{
		path: '/home',
		meta: { title: '首页' },
		redirect: '/home/index',
		component: () => import('../views/Home/index.vue'),
		children: [
			{
				path: '/home/index',
				meta: { title: '仪表盘', icon: DashboardOutlined },
				component: () => import('../views/Dashboard/index.vue')
			},
			{
				path: '/home/project',
				meta: { title: '项目', icon: AuditOutlined },
				component: () => import('../views/Project/index.vue')
			},
			{
				path: '/home/task',
				meta: { title: '任务', icon: LaptopOutlined },
				component: () => import('../views/Task/index.vue')
			},
			// 下列两项为 后台管理 admin 功能
			// {
			// 	path: '/home/organizational',
			// 	meta: { title: '组织架构', icon: 'icon-zuzhijiagou' },
			// 	children: [
			// 		{
			// 			path: '/home/organizational/index',
			// 			meta: { title: '成员与部门' }
			// 		},
			// 		{
			// 			path: '/home/organizational/position',
			// 			meta: { title: '职务职级' }
			// 		},
			// 		{
			// 			path: '/home/organizational/role',
			// 			meta: { title: '角色管理' }
			// 		}
			// 	]
			// },
			// {
			// 	path: '/home/monitor',
			// 	meta: { title: '系统监控', icon: 'icon-shujushangbao' },
			// 	children: [
			// 		{
			// 			path: '/home/monitor/index',
			// 			meta: { title: '系统日志' }
			// 		},
			// 		{
			// 			path: '/home/monitor/log',
			// 			meta: { title: '行为监控' }
			// 		},
			// 		{
			// 			path: '/home/monitor/online',
			// 			meta: { title: '在线用户' }
			// 		}
			// 	]
			// },

			{
				path: '/home/schedule',
				meta: { title: '日程', icon: 'icon-rili' },
				component: () => import('../views/Schedule/index.vue')
			},
			{
				path: '/home/knowledge',
				meta: { title: '知识库', icon: 'icon-xuexiguanli' },
				component: () => import('../views/Knowledge/index.vue')
			},
			{
				path: '/home/statistics',
				meta: { title: '统计', icon: BarChartOutlined },
				component: () => import('../views/Statistics/index.vue')
			},
			{
				path: '/home/users',
				meta: { title: '成员', icon: TeamOutlined },
				component: () => import('../views/Users/index.vue')
			},
			{
				path: '/home/message',
				meta: { title: '消息', icon: MessageOutlined },
				component: () => import('../views/Message/index.vue')
			}
		]
	}
];

const router = createRouter({
	history: createWebHistory(),
	routes
});

router.beforeEach((to, _from, next) => {
	// 处理 title
	document.title = `Easy Cooperation | ${to.meta.title}`;

	// if (to.path === '/login') {
	next();
	// } else {
	//     // 验证token
	//     const token = localForage.getItem('token');
	//     if (!token) return next('/login');
	//     next();
	// }
});

export default router;
